package mod.luckymod.blocks;

import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FlowingFluid;

import java.util.function.Supplier;

public class NaOHFluidBlock extends LiquidBlock {
    private final Supplier<FlowingFluid> fluidSupplier;

    public NaOHFluidBlock(Supplier<FlowingFluid> fluidSupplier, Properties properties) {
        super(fluidSupplier, properties);
        this.fluidSupplier = fluidSupplier;
    }

    @Override
    public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
        // 破坏船
        if(entity instanceof LivingEntity) {
            if (entity instanceof Player player) {
                player.hurt(player.damageSources().magic(), 2.0F);
            }
            entity.hurt(entity.damageSources().magic(), 3F);
        }
        super.entityInside(state, level, pos, entity);
    }
    public Supplier<FlowingFluid> getFluidSupplier() {
        return fluidSupplier;
    }
}